using System;
using System.Threading.Tasks;
using Terra.Data.Entities.Identity;

namespace Terra.Data.Repository.Identity;

/// <summary>
/// 密码重置令牌仓储接口
/// </summary>
public interface IPasswordResetTokenRepository : IRepository<PasswordResetToken, Guid>
{
    /// <summary>
    /// 根据令牌查找详细信息
    /// </summary>
    /// <param name="token">令牌字符串</param>
    /// <returns>令牌查询结果</returns>
    Task<PasswordResetToken> FindByTokenAsync(string token);

    /// <summary>
    /// 验证令牌有效性
    /// </summary>
    /// <param name="token">令牌字符串</param>
    /// <returns>元组(是否有效, 用户ID)</returns>
    Task<(bool isValid, Guid userId)> ValidateTokenAsync(string token);

    /// <summary>
    /// 使令牌失效
    /// </summary>
    /// <param name="token">令牌字符串</param>
    /// <returns>是否成功使令牌失效</returns>
    Task InvalidateTokenAsync(string token);

    /// <summary>
    /// 清理过期的令牌
    /// </summary>
    /// <returns>清理的令牌数量</returns>
    Task CleanupExpiredTokensAsync();
}